/**
 * Author:yuiop
 * Date:2022/10/24 14:10
 */
package com.devops.admin.special;

import com.devops.admin.redis.RedisService;
import com.devops.admin.service.DOSK8sResourceEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;


@Component
public class DOSK8SClientWatchApplicationRunner implements ApplicationRunner {
    @Autowired
    DOSK8sResourceEventService dosk8sResourceEventService;

    @Autowired
    RedisService redisService;

    @Value("${k8s.client.event.watch.enable}")
    private Boolean eventWatchEnable;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        if (eventWatchEnable) {
            dosk8sResourceEventService.watchAllClusterEvent();
        }
        clearRedisValue();
    }

    /**
     * @Author heyabo
     * @Description 清除redisValue
     * @Date 16:48 2023/1/10
     * @Param []
     * @return void
     **/
    private void clearRedisValue(){

        redisService.delAllKey("DEV-OPS:WEBHOOK:*");
    }
}
